package com.hxht.cmp.utils;

/**
 * @author alice on 2017/9/15 0015.
 * @version 1.0
 * @since 1.0
 */
public class FileUtil {
    static String formatFileSize(long bytes) {
        int unit = 1000;
        if (bytes < unit) return bytes + " B";
        int exp = (int) (Math.log(bytes) / Math.log(unit));
        char pre = ("KMGTPE").charAt(exp - 1);
        return String.format("%.2f %sB", bytes / Math.pow(unit, exp), pre);
    }
}
